﻿@{
    ViewBag.Title = Resources.Resource.HomeTitle;
    ViewBag.Description = Resources.Resource.HomeDesc;
    Layout = "~/Views/Shared/_Layout2.cshtml";
    var cul = System.Globalization.CultureInfo.GetCultureInfo("vi-VN");
    var user = new SmallJob.Model.User();
    if (User.Identity.IsAuthenticated)
    {
        user = SmallShop.Services.Implements.UtilityService.GetProperName(User.Identity.Name);
    }
    var lPInterest = (ViewData["provideInterest"] as List<SmallJob.Model.Provide>);
    var listF = ViewData["feature"] as List<SmallJob.Model.FeatureDisplay>;
    var lastest = ViewData["lastest"] as List<SmallJob.Model.Provide>;
    var requests = ViewData["requests"] as List<SmallJob.Model.Request>;
}
@section DifMetaData
{
    <meta property="og:url" content="http://viecnho.com" />
    <meta property="og:image" content="http://viecnho.com/Content/img/logo-square.png" />
}
<div id="singupstep2-modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3>Hoàn thiện đăng ký</h3>
    </div>
    <div class="modal-body">
        @using (Html.BeginForm("CompleteSignup", "Home", FormMethod.Post, new { Class = "form-horizontal", id = "singupstep2" }))
        {
            <fieldset>
                <div id="singupstep2-storename" class="control-group viecnho-control-group">
                    <div class="controls vn-modal-input-2">
                        <div class="input-prepend input-fullwidth">
                            <span class="add-on">viecnho.com/</span>
                            <input name="storename" class="input-large" placeholder="nickname của bạn" type="text">
                        </div>
                        <span class="help-inline"></span>
                    </div>
                </div>
                <div id="singupstep2-propername" class="control-group viecnho-control-group">
                    <div class="controls vn-modal-input-2">
                        <div class="input-prepend input-fullwidth">
                            <span class="add-on">Tôi tên là</span>
                            <input name="propername" class="input-xlarge" placeholder="Họ tên đầy đủ của bạn" type="text">
                            <span class="help-block signuptep2-help">Dùng tên thật giúp tài khoản của bạn đáng tin hơn.</span>
                        </div>
                        <span class="help-inline"></span>
                    </div>
                </div>
                <div id="singupstep2-city" class="control-group viecnho-control-group">
                    <div class="controls vn-modal-input-2">
                        <div class="input-prepend input-fullwidth">
                            <span class="add-on">Tôi sống ở</span>
                            <select name="city">
                                @foreach (var item in SmallShop.Services.Implements.UtilityService.GetCities())
                                {
                                    if (user.Location == item.Name)
                                    {
                                    <option selected="selected" value="@item.Name">@item.Name</option>
                                    }
                                    else
                                    {
                                    <option value="@item.Name">@item.Name</option>
                                    }
                                }
                            </select>
                        </div>
                        <span class="help-inline"></span>
                    </div>
                </div>
                <div id="singupstep2-job" class="control-group viecnho-control-group">
                    <div class="controls vn-modal-input-2">
                        <div class="input-prepend input-fullwidth">
                            <span class="add-on">Tôi đang làm</span>
                            <input name="job" class="input-xlarge" placeholder="nghề nghiệp, công việc của bạn" type="text">
                        </div>
                        <span class="help-inline"></span>
                    </div>
                </div>
                <div id="singupstep2-phone" class="control-group viecnho-control-group">
                    <div class="controls vn-modal-input-2">
                        <div class="input-prepend input-fullwidth">
                            <span class="add-on">Số điện thoại</span>
                            <input name="phone" class="input-xlarge" placeholder="Số di động của bạn" type="text">
                            <span class="help-block signuptep2-help">Dùng số di động thật giúp bạn nhận thông báo qua sms.</span>
                        </div>
                        <span class="help-inline"></span>
                    </div>
                </div>
                <!-- Button -->
                <div class="control-group">
                    <div class="controls vn-modal-input-2">
                        <button id="singupstep2-btn" name="save" class="btn btn-primary">Lưu</button>
                    </div>
                </div>
            </fieldset>
        }
    </div>
</div>
<div class="slideshow">
    <div class="row-fluid" id="slide-home">
        <div class="info">
            @if (!User.Identity.IsAuthenticated)
            {
                <div class="slide-box">
                    <div class="search-headline text-center">Làm theo sở thích - Tích thêm thu nhập</div>
                    <p class="sub-headline">Mở tài khoản và đăng dịch vụ trên chợ việc làm tự do chuyên nghiệp</p>
                    <p class="fb-login-button text-center">
                        <button class="btn-facebook" id="btn-fbsignup">Dùng Facebook đăng ký</button>
                    </p>
                    <p class="or text-center">hoặc điền các thông tin sau</p>
                    @using (Html.BeginForm("AddAjax", "User", FormMethod.Post, new { Class = "form-horizontal", id = "signup" }))
                    {
                        <div id="signup-email" class="control-group">
                            <div class="controls vn-modal-input">
                                <div class="input-prepend">
                                    <span class="add-on"><i class="icon-envelope"></i></span>
                                    <input type="text" name="email" placeholder="Email">
                                </div>
                                <span class="help-inline"></span>
                            </div>
                        </div>
                        <div id="signup-password" class="control-group">
                            <div class="controls vn-modal-input">
                                <div class="input-prepend">
                                    <span class="add-on"><i class="icon-edit"></i></span>
                                    <input type="password" name="password" id="signup-password-input" placeholder="Mật khẩu" data-typetoggle="#show-password" style=""><input type="text" name="undefined-clone" style="display: none;">
                                </div>
                                <span class="help-inline"></span>
                            </div>
                        </div>
                        <div class="control-group">
                            <div class="controls vn-modal-input">
                                <div class="input-prepend">
                                    <label class="checkbox" for="show-password">
                                        <input type="checkbox" name="show-password" id="show-password" value="Kiểm tra mật khẩu">
                                        Kiểm tra mật khẩu
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="control-group">
                            <div class="controls vn-modal-input">
                                <button type="submit" class="btn btn-danger" data-toggle="modal" id="signup-btn">Đăng ký</button>
                            </div>
                        </div>
                    }
                </div>
            }
            else
            {
                <div class="intro-box">
                    <div class="call-headline text-center">Làm theo sở thích - Tích thêm thu nhập</div>
                    <ul class="viecnho-features">
                        <li><h4>Tạo trang cá nhân chuyên nghiệp</h4></li>
                        <li><h4>Quảng bá dịch vụ miễn phí</h4></li>
                        <li><h4>Chăm sóc khách hàng thuận tiện</h4></li>
                    </ul>
                    <p class="call-sub-headline">Hãy bắt đầu bằng cách đăng dịch vụ phù hợp sở trường của bạn!</p>
                    <p class="text-center"><a name="sell" class="btn btn-large btn-primary" href="/them-dich-vu">Đăng dịch vụ</a></p>
                </div>
            }
        </div>
        <ul class="rslides rslides1" id="rslides-service-home">
            @foreach (var item in ViewData["bannerimage"] as List<SmallJob.Model.Banner>)
            {
                <li id="rslides1_s0" class="" style="display: block; float: none; position: absolute; opacity: 0; z-index: 1; -webkit-transition: opacity 500ms ease-in-out; transition: opacity 500ms ease-in-out;">
                    @*<img src="@((item.Url).Replace(SmallJob.Services.Code.UserUtility.GetImageBannerUpload(),"/Upload/Banner/"))" alt="">*@
                    <img src="@item.Url?w=1349&h=430&q=90&format=jpg&mode=crop" alt="" />
                </li>
            }
        </ul>
    </div>
</div>
<div class="listing-services">
    <div class="container">
		<div class="alert alert-info">
		  ViecNho.com sẽ liên tục cập nhật tính năng để xây dựng cộng đồng freelancer thiết thực và hiệu quả hơn. <strong>Mọi góp ý</strong> xin gửi về email: <a href="mailto:sm@viecnho.com">sm@viecnho.com</a>. Cảm ơn các bạn!
		</div>
		@*yeu cau moi nhat*@
	        <h2>Việc cần người làm&nbsp;&nbsp;<a class="btn btn-danger" href="/them-yeu-cau"><i class="icon-plus icon-white"></i>&nbsp;Đăng tin cần người</a>&nbsp;&nbsp;<a class="btn" href="/cho-yeu-cau"><i class="icon-th"></i>&nbsp;Xem tất cả</a></h2>
	        <div class="row">
				@{
				var length = requests.Count;
				//lap 2 lan moi lan 12 cai
					for (int i = 0; i < 2; i++)
					{
						if (length <= (12 * i)) { break; }
						<div class="span4">
							<div class="request-box">
								<ul>
								@{
								var max = (12 * (i + 1));
								//check co can lap hay ko
								//kiem tra xem lap den bao nhieu thi dung
								var end = ((length > max) ? max : length);
									for (int j = (12 * i); j < end; j++)
									{
									var r = requests[j];
									<li>
										<a rel="tooltip" data-toggle="tooltip" data-placement="top" title="" data-original-title="@(SmallJob.Services.Code.UserUtility.ShortString(SmallJob.Services.Code.UserUtility.RemoveHtml(HttpUtility.HtmlDecode(r.Description)), "300"))" href="@Url.Action("Details", "Request", new { id = r.ID })">
										@SmallJob.Services.Code.UserUtility.ShortString(r.Title, "30")

										</a> - <a href="/@(string.IsNullOrWhiteSpace(r.AssignedUser.UserName) ? r.AssignedUser.ID.ToString() : r.AssignedUser.UserName)" style="color: #666;">@r.AssignedUser.ProperName</a>
									</li>
									}  
								}
								</ul>
							</div>
						</div>
					} 
				}
				<div class="span4">
					<div class="request-box">
						<div class="fb-like-box" data-href="http://www.facebook.com/pages/Viecnhocom/493733973997031" data-width="370" data-show-faces="true" data-header="false" data-stream="false" data-show-border="true"></div>
					</div>
				</div>
	        </div>
        @foreach (var feature in listF)
        {
            <h2>@feature.Title</h2>
            <div class="row">
                @foreach (var item in feature.Provides)
                {
                    string[] image = item.ImagePath.Split(';');
                    string url = image[0] + "?w=368&h=228&q=90&format=jpg&mode=crop";
                    <div class="span4">
                        <div class="service-box">
                            <div class="service-image">
								@if (item.User.Premium) {
									<span class="vip-ribbon"></span>
								}
                                <a href="@Url.Action("Details", "Provide", new { id = item.ID })">

                                    <img src="@url" /></a>
                            </div>
                            <div class="service-description">
                                <div class="avatar">
                                    <a href="@Url.Action("Index", "User", new { username = (string.IsNullOrWhiteSpace(item.User.UserName) ? item.User.ID.ToString() : item.User.UserName) })">
                                    @{if (string.IsNullOrWhiteSpace(item.User.Avatar))
                                      {
                                        <img rel="tooltip" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="@item.User.ProperName" src="@Url.Content("~/Content/img/blank-avatar.jpg")" />
                                      }
                                      else
                                      {
                                        <img  rel="tooltip" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="@item.User.ProperName" src="@item.User.Avatar?w=40&h=40&q=90&format=jpg&mode=crop" />
                                      }
                                    }
									</a>
                                </div>
                                <div class="service-title">
                                    <a href="@Url.Action("Details", "Provide", new { id = item.ID })">
                                        <h5>@item.Title</h5>
                                    </a>
                                </div>
                                <div class="service-price">
                                    <a href="#" rel="tooltip" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="@item.Price.ToString("#,###", cul.NumberFormat)  VNĐ" style="text-decoration:none; color: #666">@SmallJob.Services.Code.UserUtility.FormatCurrency(item.Price)</a>
                                </div>
                            </div>
                        </div>
                    </div>
                }
            </div>
        }
        @*dich vu moi nhat*@
        <h2>Dịch vụ mới nhất</h2>
        <div class="row">
            @foreach (var item in lastest)
            {
                string[] image = item.ImagePath.Split(';');
                string url = image[0] + "?w=368&h=228&q=90&format=jpg&mode=crop";
                <div class="span4">
                    <div class="service-box">
                        <div class="service-image">
							@if (item.User.Premium) {
								<span class="vip-ribbon"></span>
							}
                            <a href="@Url.Action("Details", "Provide", new { id = item.ID })">

                                <img src="@url" /></a>
                        </div>
                        <div class="service-description">
                            <div class="avatar">
                                <a href="@Url.Action("Index", "User", new { username = (string.IsNullOrWhiteSpace(item.User.UserName) ? item.User.ID.ToString() : item.User.UserName) })">
                                @{if (string.IsNullOrWhiteSpace(item.User.Avatar))
                                  {
                                    <img rel="tooltip" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="@item.User.ProperName" src="@Url.Content("~/Content/img/blank-avatar.jpg")" />
                                  }
                                  else
                                  {
                                    <img  rel="tooltip" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="@item.User.ProperName" src="@item.User.Avatar?w=40&h=40&q=90&format=jpg&mode=crop" />
                                  }
                                }
								</a>
                            </div>
                            <div class="service-title">
                                <a href="@Url.Action("Details", "Provide", new { id = item.ID })">
                                    <h5>@item.Title</h5>
                                </a>
                            </div>
                            <div class="service-price">
                                <a href="#" rel="tooltip" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="@item.Price.ToString("#,###", cul.NumberFormat)  VNĐ" style="text-decoration:none; color: #666;">@SmallJob.Services.Code.UserUtility.FormatCurrency(item.Price)</a>
                            </div>
                        </div>
                    </div>
                </div>
            }
        </div>
        @*dich vu quan tam*@
        @if (lPInterest != null && lPInterest.Count > 0)
        {
            <h2>Dịch vụ bạn quan tâm</h2>
            <div class="row">
                @foreach (var item in lPInterest)
                {
                    string[] image = item.ImagePath.Split(';');
                    string url = image[0] + "?w=368&h=228&q=90&format=jpg&mode=crop";
                    <div class="span4">
                        <div class="service-box">
                            <div class="service-image">
								@if (item.User.Premium) {
									<span class="vip-ribbon"></span>
								}
                                <a href="@Url.Action("Details", "Provide", new { id = item.ID })">
                                    <img src="@url" /></a>
                            </div>
                            <div class="service-description">
                                <div class="avatar">
                                    <a href="@Url.Action("Index", "User", new { username = (string.IsNullOrWhiteSpace(item.User.UserName) ? item.User.ID.ToString() : item.User.UserName) })">
                                        @if (string.IsNullOrWhiteSpace(item.User.Avatar))
                                        {
                                            <img rel="tooltip" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="@item.User.ProperName" src="@Url.Content("~/Content/img/blank-avatar.jpg")" />
                                        }
                                        else
                                        {
                                            <img  rel="tooltip" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="@item.User.ProperName" src="@item.User.Avatar?w=40&h=40&q=90&format=jpg&mode=crop" />
                                        }
                                    </a>
                                </div>
                                <div class="service-title">
                                    <a href="@Url.Action("Details", "Provide", new { id = item.ID })">
                                        <h5>@item.Title</h5>
                                    </a>
                                </div>
                                <div class="service-price">
                                    <a href="#" rel="tooltip" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="@item.Price.ToString("#,###", cul.NumberFormat)  VNĐ" style="text-decoration:none; color: #666;">@SmallJob.Services.Code.UserUtility.FormatCurrency(item.Price)</a>
                                </div>
                            </div>
                        </div>
                    </div>
                }
            </div>
        }
    </div>
</div>
<script type="text/javascript">
    var app_id = '479862562081214';
    var app_secret = 'b58adcca0d8fa1e47fd12fc3ea18cca0';
    $('#btn-fbsignup').click(function () {
        FB.getLoginStatus(function (response) {
            if (response.status == "connected") {
                $('#fbID').val(response.authResponse.userID);
                FB.api('/me', function (resp) {
                    $('#fbname').val(resp.name);
                    $('#fbemail').val(resp.email);
                    $.ajax({
                        type: "POST",
                        url: '@Url.Action("SignUpFB", "Home")',
                        data: $('#form-loginFB').serialize(), // serializes the form's elements.
                        success: function (d) {
                            localStorage['autologin'] = true;
                            window.location = window.location;
                        },
                    });
                });
            } else {
                FB.login(function (r) {
                    if (r.status == 'connected') {
                        localStorage['autologin'] = true;
                        FB.api('/me', function (resp) {
                            $.post('@Url.Action("SignUpFB", "Home")', { fbID: resp.id, fbname: resp.name, fbemail: resp.email }, function (u) {
                                FB.api('/me/viecnho:register', 'post', {
                                    account: 'http://viecnho.com/' + u.ID
                                }, function (response) {
                                    FB.api('/me/picture?width=180&height=180', function (re) {
                                        $.post('@Url.Action("AddFBAvatar", "Home")', { fbID: u.FbID, url: re.data.url }, function (reval) {
                                        });
                                    });
                                });
                            });
                        });
                        }
                }, { scope: 'email,user_status,publish_actions' });
                }
        });
    });
        $(document).ready(function () {
            $('#form-key').ajaxForm(function (reval) {
                if (reval == true) {
                    window.location.reload();
                } else {
                    $('#group-key').addClass('error');
                    $('#group-key').find('span.help-inline').text("Mã không đúng");
                }
            });
        });
</script>